package com.rupertjones.globalcron.resources;

import org.brownflat.dbinit.upgrade.AbstractUpgradeSource;
import org.brownflat.dbinit.upgrade.Upgrade;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>&copy Rupert Jones 2011,2012</p>
 *
 * @author rup
 */
public class SpringJavaUpgradeSource extends AbstractUpgradeSource {

    @Autowired
    private List<Upgrade> upgrades;

    private Upgrade initial;

    @Override
    public List<Upgrade> getUpgrades() {
        List<Upgrade> upgradeList = new ArrayList<Upgrade>();
        upgradeList.add(initial);
        upgradeList.addAll(upgrades);
        sort(upgradeList);
        return upgradeList;
    }

    @Override
    public void setInitialUpgrade(Upgrade initial) {
        this.initial = initial;
    }
}
